<?php
	/**
	 * Utility class for sections contained in .ini-files.
	 * @author IMP
	 */

	class IniSection extends ArrayIterator {
		private $name;
		
		public function __construct($name, array $data = array()){
			parent::__construct($data);
			$this->name = $name;
		}
		
		public function setName($name){
			$this->name = $name;
		}
		
		public function getName(){
			return $this->name;
		}
		
		public function emit(){
			$emitted = '[' . $this->name . ']';
			foreach($this as $k => $v) $emitted .= PHP_EOL . IniTransformer::generateAllocationLine($k, $v);
			return $emitted;
		}
		
		public function __toString(){
			return $this->emit();
		}
		
		public function get($name, $default = null){
			if(isset($this[$name])){
				return $this[$name];
			}else{
				return $default;
			}
		}
	}
?>